Repository navigation
Conversation
Bump the module path and all internal import paths for the v2 release line. No functional changes; README/doc updates follow in a later stage. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- scripts/gen-rename.sh: regenerates rename_lmdbNN.h from nm output of a standalone compile of the pristine stream sources; fails on any defined global lacking the mdb_ prefix (symbol-hygiene guard). - update-lmdb.sh: rewritten for two streams (09/10). Writes vendored sources as prepended lines (//go:build !windows for stream 10, rename include for both) + byte-identical upstream source, applies the lmdb/patches/lmdbNN/ series with git apply, regenerates the rename header, and verifies the prepends. - scripts/check-defines.sh: guards against shared MDB_* define drift between the two vendored headers (the bindings use the 1.0 header as the single canonical surface for both engines). - lmdb/patches/: series directories with README (incl. py-lmdb attribution policy) and PATCH-STATUS template. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Both engines now compile and link into every build:
- lmdb/{mdb,midl}_lmdb09.{c,h}: pristine LMDB 0.9.35 (was 0.9.33), with
only a prepended rename include.
- lmdb/{mdb,midl}_lmdb10.{c,h}: pristine LMDB 1.0.0, prepended
//go:build !windows (1.0 is broken on Windows upstream) + rename
include. module.c (mdb_mod*) is not vendored: mdb.c never references
it, so no stubs and no -ldl.
- lmdb/rename_lmdb{09,10}.h: generated by scripts/gen-rename.sh; every
extern renamed to mdb09_*/mdb10_*. Verified: zero unprefixed global
mdb_* symbols in the test binary; the 09 symbol set matches the
anylmdb-generated list, 10 differs only by the absent mdb_mod* stubs.
- lmdb/lmdb.h + midl.h are now shim headers keyed on LMDBGO_STREAM.
TEMPORARY bridge: unstreamed consumers (cgo preambles, lmdbgo.c) get
the renamed 0.9 engine so all existing C.mdb_* call sites resolve to
mdb09_*; removed when the dispatch layer lands.
- Per-stream CHANGES/LICENSE/COPYRIGHT files; scripts/check-defines.sh
passes (shared MDB_* defines identical across streams).
Full test suite passes (on the 0.9 engine via the bridge).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Every LMDB call now crosses cgo through a thin lmdbgo2_* shim taking the
engine selector ver (9|10) as first argument and branching to the
prefixed engine symbol (LMDBGO_DISPATCH: one predicted branch to a
direct call; on _WIN32 it collapses to the 0.9 engine).
- lmdbgo_dispatch.h: prefix-parameterized extern decls of the full LMDB
surface the binding uses, included once per engine prefix; reserved
V10_ONLY section for the deferred 1.0-only APIs.
- lmdbgo_check09.c / lmdbgo_check10.c: per-stream contract TUs - the
same decls in a TU where the stream's own renamed header is in scope,
so prototype drift between an engine and the canonical surface is a
compile error; _Static_asserts pin MDB_val/MDB_stat/MDB_envinfo
layout, 64-bit-only, and constant spot checks.
- lmdbgo.{h,c}: all glue renamed lmdbgo_* -> lmdbgo2_* (v1 and v2 must
be co-importable in one binary; cgo does not hide C symbols), incl.
the //export bridge lmdbgo2MDBMsgFuncBridge. Existing data-path shims
gained the ver argument; one-line shims added for the ~35 remaining
functions.
- Go: Env/Txn/Cursor carry ver (hardcoded 9 until the sniffing stage;
Txn/Cursor copy it down); all C.mdb_* call sites now go through
C.lmdbgo2_*. Env.MaxKeySize on a nil Env returns 511 without calling
C (LMDB 1.0's implementation dereferences the env).
- lmdb.h shim: the stage-3 bridge is gone; unstreamed consumers now get
the canonical LMDB 1.0 header. Package Version()/VersionString()
report the canonical (1.0) identity; per-Env engine reporting lands
with the version API stage.
Full suite + -race pass.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The ver field grew the per-cursor allocation from 16 to 24 bytes (a size-class step visible in BenchmarkCursor). Read the selector via c.txn.ver instead: same dispatch cost, and it cannot go stale when Renew rebinds the cursor to another transaction. Cursor methods now return EINVAL (as an OpError, matching what LMDB 0.9 returned for a NULL cursor pointer) from a Go-level guard when called on a closed cursor, instead of passing NULL into C: LMDB 1.0 dereferences cursor arguments unconditionally, and nil handles must never reach the engines. This also upgrades v1's behavior for Get/Del/Count on a closed cursor from a Go panic (nil txn deref) to a clean error. Benchmarks back at parity with master (Cursor 204.8ns/16B vs 207ns/16B). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…n API Engine choice now happens in Env.Open: - lmdb/sniff.go: pure-Go SniffFormat reads the data file's first meta page (magic 0xBEEFC0DE at offset 16/0.9 or 24/1.0, mm_version 1/3) and never opens the environment - a wrong-version mdb_env_open can rewrite the lock file before it notices the mismatch. lmdb-js prerelease files (mm_version 2) get the dedicated ErrFormatUnsupported. - lmdb/version.go: LMDBVersion (V09/V10), process default SetDefaultLMDBVersion > LMDBGO_DEFAULT_VERSION env var > V09; Env.SetLMDBVersion (new databases only; explicit request vs existing format = ErrVersionConflict, never converts), Env.LMDBVersion, Env.EngineVersion (per-env engine identity). version_unix/windows.go gate V10 off on Windows. - lmdb/env.go: NewEnv no longer calls mdb_env_create; pre-open SetMapSize/SetMaxReaders/SetMaxDBs/SetFlags/UnsetFlags buffer in Go (SetFlags validates against the engines' CHANGEABLE set so EINVAL timing matches v1) and Open replays them onto the engine env after sniffing decides the version. Flags()/MaxReaders() report buffered state pre-open (exp/lmdbsync reads Flags before Open); ReaderList/ ReaderCheck emulate the engines' unopened behavior without calling C; Stat/Info/Sync/Copy*/FD/Path/BeginTxn return clean errors pre-open where v1 crashed or misbehaved; failed Open is retryable and Close is always safe. - txn.go: beginTxn refuses unopened envs; getID nil-guards. - TestTxn_OpenDBI_emptyName accepts BadValSize (0.9) or NotFound (1.0). - go.mod: go 1.17 -> 1.21 (encoding/binary.NativeEndian). Suite green on the 0.9 engine (default) incl. -race. On the 1.0 engine (LMDBGO_DEFAULT_VERSION=10) everything passes except TestTxn_finalizer, which trips upstream 1.0.0's cursor-close-after-txn-end use-after-free; that is fixed by the patch introduced in the next stage. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…onstants lmdb/patches/lmdb10/cursor-close-after-txn.patch: pristine 1.0.0's mdb_cursor_close evaluates the MDB_CURSOR_UNREF condition - which reads mc_txn->mt_env->me_flags - before its own 'read-only txn may have been freed already' guard, so the documented-legal close of a readonly cursor after txn end is a use-after-free. The patch gates the unref on C_UNTRACK: tracked (write-txn) cursors always have a live txn; for untracked cursors the unref was a no-op unless MDB_REMAP_CHUNKS is set (lmdb-go never sets it). Verified three ways: - scripts/test-cursor-close-asan.sh: standalone ASan build of the 1.0 tree + reproducer; heap-use-after-free at mdb_lmdb10.c:9765 on the pristine tree, clean with the patch. - New TestCursor_Close_afterTxn exercises the sequence on both engines. - TestTxn_finalizer (which SIGSEGVed on the 1.0 engine via the cursor finalizer) now passes; full suite green on both engines incl. -race. The patch applies with plain 'git apply' (a/b prefixes are forced when generating, independent of the user's diff.noprefix config) and is documented in lmdb/patches/PATCH-STATUS.md with re-derivation notes. error.go: the eleven LMDB 1.0 error constants (Problem, BadChecksum, CryptoFail, EnvEncryption, TxnPending, CantRollback, DBIsBusy, ShortWrite, EnvBusy, IsReadonly, AddrBusy) are now defined unconditionally from the canonical header; maxErrno already spans them via MDB_LAST_ERRCODE. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- sniff_test.go: sniffing of real 0.9/1.0 databases, NoSubdir, missing/ empty files, and fixture files (lmdb-js data version 2 at either page header size -> ErrFormatUnsupported; unknown versions; bad magic); Open() surfaces the sniffer's precise error for unsupported formats. - version_test.go: version introspection, explicit-request-vs-existing- format conflict in both directions, existing-format-wins over the process default, default resolution precedence (setter > env var > V09), and the flagship cross-format test: a 0.9 and a 1.0 environment open simultaneously in one process, written and read independently. - preopen_test.go: buffered pre-open setters and their replay at Open, EINVAL parity for non-changeable flags and post-open setters, MaxReaders default 126, MaxKeySize (511 pre-open and on 0.9; the 1.0 engine computes it from the page size - 8122 for 4K pages), clean errors where v1 crashed, double-Open EINVAL, Open retry after failure, Close-before-Open. - tests/coexist/: separate Go module importing lmdb-go v1 AND v2 in one test binary. Links (proving there are no duplicate C symbols) and passes: v1-written databases open in v2 (sniffed as 0.9) and vice versa; a 1.0-format database is rejected by v1 but sniffed and opened by v2. Run with 'make coexist-test' (needs network for v1). - Env.MaxKeySize now never reaches C without an open engine env. - Makefile: test/full-test run the suite once per engine; check-c runs the define-parity and ASan checks; bench target for benchstat runs. - CI: make all now covers both engines; symbol-hygiene job (no unprefixed mdb_* globals in the test binary); coexistence job; Windows cross-build job with mingw (verified locally: windows/amd64 builds with the 0.9 engine only, 1.0 tree excluded by //go:build). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The full benchmark A/B against master showed Get_*_alloc_* B/op +16: appending the ver field grew Txn from exactly 64 bytes into the 80-byte allocation size class. Declaring ver right after the four bools fills their padding and restores 64 bytes. sizeof_test.go pins Txn at 64 and Cursor at 16 bytes so future field additions cannot silently bump the per-allocation size class again. Full-run benchstat vs master (0.9 engine, n=6): sec/op geomean -1.85%, no benchmark regressed beyond +2.5%; B/op now identical to master. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- README: v2 section explaining the bundled 0.9.35 + 1.0.0 engines, per-environment selection via sniffing, the 0.9 default for new databases and how to opt into 1.0, simultaneous cross-format use, v1+v2 co-importability, the Windows 0.9-only caveat, and the local patch policy. Import paths and badges updated for /v2. - CHANGES.md: full v2.0.0 section - new API, internals, and the v1 -> v2 behavior-difference register, including measured benchmark results (vs v1 same-engine: sec/op geomean -1.9%, B/op identical; 0.9-vs-1.0 engine profile: readonly txn creation is costlier on 1.0, renewed txns at parity, subtransactions faster). - RELEASING.md: v2.X.Y tag scheme, per-stream update-lmdb.sh flow with patch re-derivation, and the release validation checklist (both engines, coexistence, benchstat). - Package docs: 'LMDB versions' section in the lmdb package doc. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
anylmdb is itself an AI-generated experiment, so every fact v2 took from it was re-verified against the vendored sources (or externally): Verified correct, comments upgraded to cite the in-source evidence: - Lock-file-before-header order: both engines call mdb_env_setup_locks before mdb_env_open2/mdb_env_read_header, so probing with the wrong engine can race a correct-version open (the reason SniffFormat never opens the environment). - Data format versions: MDB_DATA_VERSION is 1 (0.9.35) and 3 (1.0.0); 999 for MDB_DEVEL builds (the sniffer's unknown-version path). - Data version 2 = lmdb-js: confirmed against kriszyp/lmdb-js's own vendored mdb.c (MDB_DATA_VERSION ((MDB_DEVEL) ? 999 : 2)), no longer resting on the anylmdb README. - 'Close a read-only cursor before or after its transaction ends' is documented verbatim in BOTH vendored headers (the basis for the cursor-close-after-txn patch). - CHANGEABLE flags identical in both engines (pre-open SetFlags validation is correct for both); DEFAULT_READERS 126 in both; the meta-page offsets used by the sniffer match both struct definitions; the rename headers were already independently generated from nm output, not copied. Fixed: - Env.MaxKeySize comment wrongly claimed 511 is both engines' default. 511 is 0.9's compile-time MDB_MAXKEYSIZE; LMDB 1.0 derives the limit from the page size (8122 for 4K pages) and its getter dereferences the env. Behavior unchanged (pre-open 511 matches v1); the comment now states the facts. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
LMDB 1.0 only: opens the environment with the previous snapshot rather than the latest one (corruption workaround; requires exclusivity for write access, auto-resets after a successful write commit). The 0.9 engine has no equivalent and rejects the unknown flag bit with EINVAL. Tested on both engines: a 1.0 environment reopened with PrevSnapshot|Readonly serves the previous transaction's data; a 0.9 environment fails with EINVAL. Note the sniffer needs no special handling for the recovery case: LMDB 1.0's own mdb_env_read_header requires a structurally valid first meta page just like SniffFormat does - PrevSnapshot recovers from a bad latest *transaction*, not from a corrupt meta page header. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Resolves both golint findings from CI properly, without suppression: - The type models the on-disk format (mapping 1:1 to an engine line), and the API was already half format-named (SniffFormat, FormatUnknown, ErrFormatUnsupported, and all prose). Renamed: LMDBVersion -> Format, Env.SetLMDBVersion/LMDBVersion -> SetFormat/Format, SetDefaultLMDBVersion -> SetDefaultFormat, ErrInvalidVersion -> ErrInvalidFormat, ErrVersionConflict -> ErrFormatConflict, and the env var LMDBGO_DEFAULT_VERSION -> LMDBGO_DEFAULT_FORMAT (Makefile, CI, docs updated). V09/V10 and the engine-version APIs (EngineVersion, EnvVersion, ErrVersionUndetermined) keep their names; 'version' now consistently means the engine's x.y.z, 'format' the on-disk format. This also removes the Env.LMDBVersion vs Env.EngineVersion ambiguity. - requireOpen had been inserted between CopyFD's doc comment and the method, leaving CopyFD undocumented; reordered. golint is clean again with no filtering. Both-engine suites and the v1+v2 coexistence test pass. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
A pass over the full rendered go doc output plus every site where this branch inserted code near existing comments found and fixed: - The internal c.txn.ver layout note had merged into the exported Cursor type's doc comment (same failure mode as the earlier CopyFD case); it now lives inside the struct. - Rename leftovers where 'version' still meant the on-disk format: Format()/SetFormat/SetDefaultFormat/DefaultFormatEnvVar/ ErrFormatConflict/ErrInvalidFormat docs and the two error strings, the Open and NewEnv docs, the Format type doc, FormatUnknown, and the SniffFormat opening line. 'Version' now consistently refers to an engine's x.y.z (EngineVersion, EnvVersion, ErrVersionUndetermined, package Version). - 'an Format' grammar slip; 'Version return the' -> 'Version returns'. No behavior changes; golint clean; both-engine suites pass. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
GNU mktemp requires a template with X's ('-t prefix' is a BSD-ism that
only worked on macOS; CI failed in check-defines.sh). All four scripts
now use the portable operand form:
mktemp -d "${TMPDIR:-/tmp}/name.XXXXXX"
Verified locally: check-defines, gen-rename (regenerated headers are
byte-identical), and the ASan reproducer all still pass on macOS.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Open the README with a pointer to the v1 branch, then explain in plain language what v2 is: both LMDB 0.9 and 1.0 bundled, engine picked per environment at Open, existing databases auto-detected, new databases 0.9 by default with an example of opting into 1.0. Add upgrade instructions (import path change, existing databases keep working, things to be aware of) and move the technical material below that. Give the v2.0.0 changelog entry the same plain-language intro. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011JzENKdjvhRh8q8JBR9CrD
mdb_reader_check reports 0 cleared entries for an environment that was never opened. Instead of emulating that, ReaderCheck now goes through the same requireOpen guard as Stat, Info and the other post-open methods, so calling it before Open (or on a zero-value Env) yields a clear error. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011JzENKdjvhRh8q8JBR9CrD
Vendored via ./update-lmdb.sh 10 1.0.1. Upstream changes (2026/08/06): ITS#10529 - invalidate DBIs in rollback ITS#10534 - update mdb_env_get_maxkeysize() doc ITS#10536 - re-fix mdb_drop(MAIN_DBI) ITS#10538 - fix large writes on Windows ITS#10539 - Windows build fixes ITS#10540 - cleanup outdated license notices ITS#10542 - Windows buffered/writethru write behavior ITS#10551 - fix mdb_page_split nodesize calculation ITS#10553 - Another Windows build fix The cursor-close-after-txn patch is still needed: the mdb_cursor_close region is unchanged upstream, the patch applies at a 25-line offset, and the ASan reproducer stays clean. The 1.0 tree remains excluded on Windows; 1.0.1 fixes the upstream build breakage but enabling the engine there is a separate change. Version references in the README, CHANGES.md, PATCH-STATUS.md and the update script are bumped to 1.0.1. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011JzENKdjvhRh8q8JBR9CrD
LMDB 1.0.1 builds on Windows, so the 1.0 stream no longer needs to be excluded there. Both engines are now compiled into every build on all platforms: - Drop the //go:build !windows prepend from the stream-10 sources and from update-lmdb.sh. - Rename mdb_tls_cbp: both engines define this TLS-callback global under #ifdef _WIN32, invisible to gen-rename.sh's nm run on a unix host. It now comes from an explicit win_syms list, verified against a real mingw-w64 compile when the cross toolchain is installed (mingw's generated .refptr.* comdat stubs are excluded from that check). - lmdbgo.c: drop the _WIN32 special cases; declaration and dispatch are identical on every platform. - Remove the v10Available concept entirely (version_unix.go / version_windows.go, the guards in version.go, env.go and lmdb.go, and the test skip-guards): it existed only for the Windows exclusion. - Docs: delete the Windows caveats from the package doc, README and CHANGES.md. - CI: add a windows-test job running the suite on a Windows runner for both engines; the mingw cross-build job remains as the cheap compile/link check. Verified: full test suite passes on Windows 10 (amd64) with both LMDBGO_DEFAULT_FORMAT values, plus the usual suite on macOS. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019bk39Agd1i4rzLrDXPFoEZ
The lmdbsync TestResize helper was built as plain "testresize", which Windows cannot exec without the .exe extension, failing the new CI windows-test job. Add the extension on Windows. The scenario the test exercises was verified on a real Windows 10 machine: two testresize processes ping-ponging updates on an NTFS database both complete successfully, resizing the map and adopting each other's new map size along the way. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019bk39Agd1i4rzLrDXPFoEZ
mdb_cursor_renew only validates the DBI index against the new txn; it never checks that the cursor belongs to the same environment. In v1 that silently used the cursor in the wrong environment. In v2 it is also a memory-safety issue: the C cursor was allocated by the engine of the environment it was opened in, and the two engines lay out MDB_cursor differently (1.0 carries an extra overflow-page pointer), so renewing a 0.9 cursor through the 1.0 engine writes past its allocation. Renew now returns EINVAL before entering C when the transaction's Env differs from the cursor's. A test covers all four engine pairings and checks that a failed Renew leaves the cursor usable in its own Env. Found by an adversarial Codex review of the branch. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011JzENKdjvhRh8q8JBR9CrD
Adds a macos-test job (macos-latest, Apple Silicon) running `make check-c full-test`: the shared-define check, the ASan cursor-close reproducer built with Apple clang, and the full suite once per engine, plain and with -race. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011JzENKdjvhRh8q8JBR9CrD
The env close cleanup was registered before t.TempDir registered its
removal, so with last-in-first-out cleanups the directory was removed
while the first environment still had data.mdb mapped. Unix unlinks open
files; Windows refuses ("being used by another process"). Create the
directory before registering env.Close.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011JzENKdjvhRh8q8JBR9CrD
| @@ -7,6 +7,7 @@ on: | |||
| push: | |||
| branches: | |||
| - master | |||
There was a problem hiding this comment.
v1 will become the "v1" branch
v2 will be the new master branch
|
|
||
| # Defined global symbols (text/data/bss/common), leading underscore stripped | ||
| # (darwin). Undefined (U) references are naturally excluded. | ||
| syms="$(nm -g "$tmp/mdb.o" "$tmp/midl.o" 2>/dev/null \ |
There was a problem hiding this comment.
@Luit You suggested that symbols could be found by simply using the C preprocessor.
Codex gave the following explanation for this approach:
Because the C preprocessor expands macros and selects #ifdef branches, but doesn’t determine which identifiers define externally linked symbols. That requires understanding C declarations and linkage, or inspecting the compiled object.
In scripts/gen-rename.sh:71, nm gives exactly the relevant set: defined global functions and variables, excluding static helpers and undefined references. This includes internal globals such as the mdb_midl_* functions, beyond LMDB’s public API. It also lets the script reject unexpected globals without the mdb_ prefix.
You could preprocess the sources and collect every mdb_* identifier, then rename that larger set. Renaming static helpers too is generally harmless. But that would be a different strategy:
- It would also collect types, local names, and other identifiers that don’t need renaming.
- It wouldn’t detect unexpected globals outside the mdb_ namespace.
- It would still miss inactive platform branches, so the Windows-only mdb_tls_cbp issue remains.
So nm isn’t essential for generating a conservative rename list; it’s useful because it also audits what the compiled engine actually exposes. A preprocessor-based approach would need C parsing to provide the same precision, or a separate symbol check to provide the same assurance.
Since the exposed globals are also dependent on platform and compile defines anyway, I am not too attached to this approach. If we also find that other symbols do not leak outside of this module in CGo builds, we could simply maintain of a static list, but that may not be the case with two LMDB libraries compiled together in the same module. Even if they do no leak outside of this module, they may clash within this module.
WIP — this PR becomes lmdb-go v2 (
github.com/PowerDNS/lmdb-go/v2). The v1 series continues on its own branch withv1.x.yreleases.Branch plan:
Reviewers: does this make sense?
What is v2?
lmdb-go v2 ships both LMDB 0.9 and LMDB 1.0 in one Go module, and lets a program use either of them, or both, at runtime.
LMDB 1.0 (released June 2026) stores data in a new on-disk format that LMDB 0.9 cannot read, and vice versa. Both C libraries use the same function names, so a normal program can link only one of them: it either reads old databases or new ones. v2 removes that choice by bundling both engines under distinct symbol names and picking an engine per environment when it is opened. This is the approach discussed in #41 and the one py-lmdb took (jnwatson/py-lmdb#479).
env.SetFormat(lmdb.V10)beforeOpen, process-wide withlmdb.SetDefaultFormat, or withLMDBGO_DEFAULT_FORMAT=10.Upgrading from v1
The Go API is drop-in compatible with v1. Upgrading is an import path change:
github.com/PowerDNS/lmdb-go/...becomesgithub.com/PowerDNS/lmdb-go/v2/.... Existing databases keep working unchanged, and new databases stay in the 0.9 format unless you opt in.Things to be aware of:
EnvbeforeOpen(Stat,BeginTxn,ReaderCheck, ...) returns a clear not-open error, methods on a closed cursor returnEINVAL, and a failedOpencan be retried.lmdb.Versionreports the newest bundled engine (1.0.x). Useenv.EngineVersion()for the engine driving a specific environment.env.MaxKeySize()depends on the engine.Formattype (V09/V10),SniffFormat,Env.Format/EngineVersion, the LMDB 1.0 error constants, and thePrevSnapshotopen flag (1.0 only).The README opens with all of this (plus a pointer to the v1 branch for people who land on the wrong version), and
CHANGES.mdhas the complete list of v1 → v2 behavior differences.How it works
mdb09_*/mdb10_*(scripts/gen-rename.sh, fromnmoutput). The Windows-onlymdb_tls_cbpglobal is invisible tonmon a unix host, so it comes from an explicit list that is checked against a real mingw-w64 compile when that toolchain is installed.lmdbgo2_*C shim that takes anint verand branches to the prefixed symbol. Per-stream check translation units turn any prototype or layout drift into a compile error. The shim is identical on all platforms.Open, so nothing can reach C before the engine is known.tests/coexist/links v1 and v2 into one binary and cross-reads database files.lmdb/patches/holds per-stream patch series applied byupdate-lmdb.sh. v2 ships a fix for a use-after-free in LMDB 1.0.x when a read-only cursor is closed after its transaction ended, a sequence LMDB documents as legal and that lmdb-go finalizers rely on. It is still needed in 1.0.1 and has an ASan reproducer (scripts/test-cursor-close-asan.sh). The infrastructure is ready for importing the py-lmdb security series later.LMDB 1.0.1
The 1.0 stream was bumped from 1.0.0 to 1.0.1 (upstream release of 2026-08-06). The upstream fixes that matter here: dropping the main DBI now drops the named databases and leaves the transaction usable (ITS#10536), the page-split size accounting matches the real page layout (ITS#10551), rollback as used by
PrevSnapshotwrites a consistent meta page (ITS#10529), and the Windows build, large-write, and write-through fixes (ITS#10538, #10539, #10542, #10553).Validation
-race. CI runs both engines, plus symbol-hygiene, coexistence, and Windows jobs.windows-testjob on a Windows runner, and the mingw cross-build job remains as the cheap compile-and-link check.Txn/Cursorsize classes pinned by a test.mdb.c.Not in this PR (deferred)
lmdb/patches/and its attribution README are ready for it).mdb_txn_prepare, encryption and checksums). The dispatch layer reserves aV10_ONLYsection.🤖 Generated with Claude Code